const express = require('express');
const router = express.Router();
const multer = require('multer');
var storage = multer.diskStorage({
    destination: function (req, file, cb) {
        cb(null, 'public/images/')
        //文件保存路径
    },
    filename: function (req, file, cb) {
        console.log(file.originalname)
        cb(null, file.originalname)
        //存储文件名
    }
})
const upload = multer({ storage: storage })
router.post('/', upload.single("file"), (req, res,next) => {
    res.send({
        msg:{code:200,msg:'成功'},
        file:req.file
    })
})
router.get('/test',(req,res)=>{
    res.send('The Service Is OK! No Problem!')
})
router.post('/a',(req,res)=>{
    console.log(req)
    res.send(req.body)
})

module.exports = router
